package com.lp.module_lib.dialog;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.View;
import android.widget.TextView;

import com.lp.module_lib.R;

/**
 * 作者：created by LP_TREAM on 2020/11/25 23:59
 * 邮箱：806875201@qq.com
 */
public class LoadingDialog extends Dialog {
    private TextView mTvText;

    public LoadingDialog(Context context) {
        super(context, R.style.BaseDialogStyle);
        initView();
    }

    private void initView() {
        try {
            Context contexts = this.getContext();
            int dividerID = contexts.getResources().getIdentifier("android:id/titleDivider", null, null);
            View divider = this.findViewById(dividerID);
            if (divider != null) {
                divider.setBackgroundColor(Color.TRANSPARENT);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        setContentView(R.layout.dialog_loading);
        mTvText = findViewById(R.id.tv_text);
        setCanceledOnTouchOutside(false);
    }

    public LoadingDialog setMessage(String message) {
        mTvText.setText(message);
        return this;
    }
}
